<?php
session_save_path('sessions');
session_start();

include("include/dbUserTypes.php");

// Include our user class
include_once("include/user.php");

// Create a variable to store our user if we're validated
$user = null;

// Check if we're in a valid session. If not, go back to main login page.

if( !isset($_SESSION['user']) || $_SESSION['user'] == null ) {
    header("location:main_login.php");
}
else {
    // Unserialize our user to turn it back into a useful object
    $user = unserialize($_SESSION['user']);
}

// If we're not a business (or admin) go back to the user redirection page
if( $user->getUserType() != $USERTYPE_REGISTERED && $user->getUserType() != $USERTYPE_ADMIN)
    header("location:login_success.php");


// Include the header (CSS files, etc)
include("include/dbconnection.php");
include("include/header.php"); ?>
<body>
  <div id="wrapper">
    <div id="header"> </div>
    <div id="left">
      <div id="logo">
        <h1>Home Sale</h1>
        <p>Only By Owner</p>
      </div>
      <div id="nav">
		  <ul>
        <li>
          <a href="addAhomeForSale.php">Add a House for sale</a>
        </li>
        <li>
          <a href="updateAhome.php">Update House information</a>
        </li>
        <li class="important">
          <a href="updateAhomePicture.php">Update House picture</a>
        </li>
        <li>
          <a href="searchhouse.php">Search House</a>
        </li>
        <li>
          <a href="emailMenu.php">Mailbox</a>
        </li>
        <li>
          <a href="logout.php">Logout</a>
        </li>
		  </ul>
      </div>
      <div id="news">
        <?php include("adgeneratorleft1.php");?>
        <div class="hr-dots"> </div>
        <?php include("adgeneratorleft2.php");?>
        <p class="more"><a href="index.php">more</a></p>
      </div>
      <div id="support">
      </div>
    </div>
    <div id="right">
      <h2>Welcome to Our Site!</h2>
      <div id="welcome">
        <?php
        if(isset($_SESSION["returnCode"])) {
            ?>
        <div id="error">
          <?php echo $_SESSION["returnCode"]; unset($_SESSION["returnCode"])?>
        </div>
        <?php
        }?>
		  
		  <?php
		  $homeID = $_GET['homeID'];
		   ?>
		  
	    <h4><b>Upload Image or Video:</b></h4>
        <form action="upload_file.php" method="post" enctype="multipart/form-data">
          <label for="file">Filename:</label>
          <input type="file" name="file" id="file" />
			<input type="hidden" name="homeID" value = "<?php echo $homeID ?>" >
			<input type="submit" name="submit" value="Submit" />
        </form>
        <h4>File size limit is 2MB</h4>
      </div>
      <h3></h3>
      <div id="profile">
        <div id="corp">
          <?php include("adgeneratorbottomleft.php");?>
        </div>
        <div id="indu">
          <?php include("adgeneratorbottomright.php");?>
        </div>
        <div class="clear"> </div>
        <p class="more"><a href="index.php">View Details</a></p>
      </div>
    </div>
    <div class="clear"> </div>
    <div id="spacer"> </div>
    <div id="footer">
      <div id="copyright">
        &copy; Template taken from http://www.freewebsitetemplates.com/
      </div>
	  <div id="footerline"></div>
    </div>
	
  </div>
</body>
</html>